let cc = document.querySelector(".cc");
let all = document.querySelector(".kk");



let input = document.querySelectorAll("input")
cc.onclick = () => {

  if (all.checked == true) {

    let params = {
      username: input[0].value.trim(),
      password: input[1].value.trim(),
    };

    const baseUrl = "http://localhost:8888";
    ajax({
      url: baseUrl + "/users/login",
      type: "post",
      params,
      fn(data) {
        let datas = JSON.parse(data);
        console.log(datas);
        if (datas.code == 0) {
          errorSpan.innerText = "请重新确定账号密码" + datas.message;
          console.log(errorSpan.innerText);
        }
        if (datas.code == 1) {
          location.href = 'index.html';
          clearInterval(timer);


          localStorage.setItem('token', res.token);
          localStorage.setItem('uid', res.user.id);
          localStorage.setItem('nickname', res.user.nickname);
          localStorage.setItem('identity', res.user.identity);
          localStorage.setItem('flag', 1);



        }
      },
    });
  } else {
    var name = '请同意协议,后继续注册';
    var htmlStr = `<div><span>${name}</span></div>`

    document.querySelector('.box').innerHTML = htmlStr;
  }


}




